"""单例装饰器"""


def Singleton(cls):
    _instance = {}

    def _singleton(*a, **b):
        if cls not in _instance:
            _instance[cls] = cls(*a, **b)
        return _instance[cls]

    return _singleton


@Singleton
class Test:
    pass


test1 = Test()
test2 = Test()

assert test1 is test2, "不是单例"
